<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div class="container">
      <div class="pointer"></div>
      <div class="item">
        <div class="item_bg"></div>
      </div>
      <div class="item">
        <div class="item_bg"></div>
      </div>
      <div class="item">
        <div class="item_bg"></div>
      </div>
      <div class="item">
        <div class="item_bg"></div>
      </div>
      <div class="item">
        <div class="item_bg"></div>
      </div>
      <div class="item">
        <div class="item_bg"></div>
      </div>
      <div class="item">
        <div class="item_bg"></div>
      </div>
      <div class="item">
        <div class="item_bg"></div>
      </div>
      <div class="item">
        <div class="item_bg"></div>
      </div>
    </div>
  </body>

  <style>
    body {
      width: 100%;
      height: 100vh;
      display: flex;
      justify-content: center;
      align-items: center;
      background: black;
    }
    .item_bg {
      width: 250px;
      height: 250px;
      background-color: blue;
    }
    .container {
      margin: 0 auto;
      width: 1000px;
      height: 850px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-wrap: wrap;
      flex-shrink: 1;
      gap: 20px;
      /* background-color: red; */
      position: relative;
    }
    .pointer {
      box-sizing: border-box;
      position: absolute;
      --l: 30px; /* 四角线框的长度 */
      --t: 3px; /* 四角线框的厚度 */
      --g: 20px; /* 四角线框到图片的间隙 */
      --s: 250px; /* 图片的尺寸 动态 */
      --x: 0px; /* 图片的左上角的横坐标 动态 */
      --y: 0px; /* 图片的左上角的纵坐标 动态 */
      width: calc(var(--s) + 2 * var(--g));
      height: calc(var(--s) + 2 * var(--g));
      border: var(--t) solid #fff;
      top: calc(var(--y) - var(--g));
      left: calc(var(--x) - var(--g));
      transition: 0.3s;
      mask: conic-gradient(at var(--l) var(--l), transparent 75%, blue 75%) 0 0 / calc(100% - var(--l))
        calc(100% - (var(--l))) repeat;
    }
  </style>

  <script>
    const imgs = document.querySelectorAll('.item .item_bg');
    const pointer = document.querySelector('.pointer');

    imgs.forEach(img => {
      img.addEventListener('mouseenter', e => {
        pointer.style.setProperty('--s', img.offsetWidth + 'px');
        pointer.style.setProperty('--x', img.offsetLeft + 'px');
        pointer.style.setProperty('--y', img.offsetTop + 'px');
      });
    });
  </script>
</html>
